const {PrismaClient}=require('@prisma/client')
const prisma=new PrismaClient({
    errorFormat:'pretty'
})

///////////

require('dotenv').config()

const Minio=require('minio')
const minioClient=new Minio.Client({
    endPoint:'localhost',
    port:9000,
    useSSL:false,
    accessKey:process.env.accessKey,
    secretKey:process.env.secretKey
})

//////////

const mqtt=require('mqtt')
const options={
    clear:true,
    connectionTimeOut:4000,
    clientId:process.env.clientId
}
const mqttClient=mqtt.connect(process.env.connectUrl,options)
mqttClient.on('reconnect',err=>{console.log('mqtt重连：',err)})
mqttClient.on('error',err=>{console.log('mqtt连接失败：',err)})
mqttClient.on('message',(topic,message)=>{
    console.log('收到消息：',topic,message.toString())
})
mqttClient.subscribe('/backend/#')

module.exports={prisma, minioClient, mqttClient}